const { contextBridge, ipcRenderer } = require('electron')

/**
 * 通用的进程间通信数据结构
params结构
{
  event: "launch",
  params: [param1, param2, ...]
}
*/

// for game
contextBridge.exposeInMainWorld('gameAPI', {
  call: (params) => ipcRenderer.send('game.call', params),
  invoke: (params) => ipcRenderer.invoke('game.invoke', params),
  onNotify: (callback) => ipcRenderer.on('game.notify', (_event, params) => callback(params)),
})


contextBridge.exposeInMainWorld('tonwebAPI', {
  call: (params) => ipcRenderer.call('tonweb.call', params),
  invoke: (params) => ipcRenderer.invoke('tonweb.invoke', params),
  onNotify: (callback) => ipcRenderer.on('tonweb.notify', (_event, params) => callback(params)),
})
